package com.coda.service.impl;

import com.coda.entity.FacilityInfo;
import com.coda.mapper.FacilityMapper;
import com.coda.service.FacilityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

@Service
public class FacilityServiceImpl implements FacilityService {
    @Autowired
    private FacilityMapper facilityMapper;
    /**
     * 新增或删除配套信息
     * @param facilityInfo
     */
    @Override
    public void saveOrUpdate(FacilityInfo facilityInfo) {
        if (facilityInfo.getId() == null){
            facilityMapper.insert(facilityInfo);
        }else {
            facilityMapper.update(facilityInfo);
        }


    }

    /**
     * 查询配套信息列表
     * @return
     */
    @Override
    public List<FacilityInfo> getFacilityList() {
        List<FacilityInfo> facilityInfos = facilityMapper.list();
        return facilityInfos;
    }

    /**
     * 根据id删除配套信息
     * @param id
     */
    @Override
    public void deleteById(Long id) {
        facilityMapper.delete(id);
    }
}
